package com.zyg.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class LoginController {
    @RequestMapping("/")
    public String login(){
        return "login";
    }

    @RequestMapping("/imgCode")
    @ResponseBody
    public String imgCode(){
        //调用hutool验证码工具类生成验证码
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
        String code = captcha.getCode();
        return JsonUtil.toJSONString(lineCaptcha.getImageBase64());

    }
}
